﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tomahawk.Runtime.Logic;
using System.Xml.Serialization;

namespace ActorsAndComponents.Logic
{
    //
    // This example actor class demonstrate how you can add a component 
    // directly in the archetype
    //

    public class InlinedInArchetype : XActor
    {

        // This will be assigned to an already existing component during initialization
        XMaterialMeshComponent staticMesh;

        protected override void OnInitialize()
        {
            base.OnInitialize();

            // The archetype "InlinedComponent.xml" had already added a component of type XStaticMeshComponent.
            // If we want to hace direct access to this component, we can retrieve it with GetComponentOfType
            // It will return the first component of that kind found in the Component array

            staticMesh = (XMaterialMeshComponent)this.GetComponentOfType(typeof(XMaterialMeshComponent));

            // If you use more than one component of the same type, you can still retrievent them manually from the
            // Components array

        }

    }
}
